<!-- 
 Copyright 2009 University of  Washington
This code is released under the GPL version 3 - with a copy of the license included
@author Maya Hao Li
 -->
<%@ page import="seedpod.model.custom.SeedpodUser"%>
<%@ page import="seedpod.webapp.LimsSession"%>
<%@ page import="seedpod.webapp.LimsContext"%>
<%@ page import="java.io.File"%>
<%@ page import="seedpod.webapp.Seedpod"%>
<%@page import="java.util.Date"%>

<%
	LimsSession _session = LimsSession.getSession( request );
	SeedpodUser user = _session.getUser();
%>

<div id="banner">
<div id="topMenuBar">
<%
		Date now = new Date();
		out.println( "<span id=\"currentTime\">" + now.toString() + "</span>" );
 %>
<ul id="topMenu">
	<%

		String homeUrl = Seedpod.getAbsoluteUrl( LimsContext.HOME_URL );
		String logoutUrl = Seedpod.getAbsoluteUrl( "logout" );
		String signinUrl = Seedpod.getAbsoluteUrl( "signin.jsp" );
		out.println( "<li id=\"home\"><a class=\"menuItemLink\" href=\"" + homeUrl + "\">Home</a></li>" );

		if ( user != null ) {
			out.println( "<li id=\"user\"><a class=\"menuItemLink\" href=\"#\">" );
			out.println( "Logged in as " );
			out.println( user.getUserName() );
			out.println( "</a></li>" );
			out.println( "<li id=\"logout\">" );
			out.println( "<a class=\"menuItemLink\" href=\"" + logoutUrl + "\">Log out</a></li>" );

		} else {
			out.println( "<li id=\"user\">You are not signed in yet. " );
			out.println( "<a class=\"menuItemLink\" href=\""+signinUrl+"\">Sign in</a>" );
			out.println( "</li>" );
		}

		String dir = "pages";
		File pagesFolder = new File( dir);
		
		if ( pagesFolder != null && pagesFolder.isDirectory() ) {
			File[] files = pagesFolder.listFiles();
			for ( int f = 0; f < files.length; f++ ) {
				String fname = files[f].getName();

				String absUrl = Seedpod.getAbsoluteUrl( dir + "/" + fname );
				String displayName = fname.substring( 0, fname.lastIndexOf( "." ) );
				out.println( "<li><a class=\"menuItemLink\" href=\"" + absUrl + "\">" + displayName + "</a></li>" );
			}
		} else
			out.println(pagesFolder.getName());
	%>

</ul>
</div>
<!-- end topmenubar -->
<div id="icon"><img src='<%=Seedpod.getAbsoluteUrl("/images/sp_icon.gif") %>' alt=""></div>
<div id="LIMSTitle"><%=LimsContext.getLimsName()%></div>


<!--  end banner div --></div>
